﻿using System;
using System.Collections.Generic;

namespace memo
{
    /// <summary>
    /// A DataAccessort helyettesíti a RAMban tárolt tárolással. Ugyanúgy használható a Load és a Save, mint a DataAccessorban.
    /// Kezdetben feltölti a tárát egy pár adattal.
    /// </summary>
    public class MockDataAccessor : IDataAccessor
    {
        /// <summary>
        /// Az adatok helye. Kívülről nem látható.
        /// </summary>
        private List<Topic> data = new List<Topic>();

        /// <summary>
        /// MockDataAccessor létrehozása és feltöltése 10 elemmel.
        /// </summary>
        public MockDataAccessor()
        {
            this.GenerateNiceData();
        }

        public void GenerateNiceData()
        {
            List<Content> contents = new List<Content>();

            contents.Add(new Content("Head tag","The <head> </head> contains metadata about the HTML page, like charset, language, author, title.", null, null, null, null) );
            contents.Add(new Content("Body tag", "The <body> </body> contains the controls of the webpage. It holds all the content like text, images and buttons.", null, null, null, null));
            contents.Add(new Content("H1-H5 tag", "The <h1> </h1> (or 2-5) are headlines for text, to organise text structure. The h1 is the biggest and h5 is the smallest.", null, null, null, null));
            contents.Add(new Content("P tag", "Holds a simple paragraph of text. Can contain internal text styling, and other objects.", null, null, null, null));
            contents.Add(new Content("Lists", "Ordered: <ol> </ol> Ordered: <ul> </ul> List element: <li> </li>", null, null, null, null));
            contents.Add(new Content("Tables", "asd", null, null, null, null));

            List<SubTopic> subTopics = new List<SubTopic>();

            subTopics.Add(new SubTopic("HTML", "HTML", contents, "html5.png"));
            subTopics.Add(new SubTopic("CCS", "CCS", null, "css3.png"));
            subTopics.Add(new SubTopic("JavaScript", "JavaScript", null, "js.png"));
            subTopics.Add(new SubTopic("PHP", "PHP", null, "php.png"));
            subTopics.Add(new SubTopic("ASP.NET", "ASP.NET", null, "asp_net.png"));
            subTopics.Add(new SubTopic("Bootstrap", "Bootstrap", null, "bootstrap.png"));
            subTopics.Add(new SubTopic("JQuery", "JQuery", null, "jquery.png"));
            subTopics.Add(new SubTopic("AngularJS", "AngularJS", null, "angular.png"));
            subTopics.Add(new SubTopic("Node.js", "Node.js", null, "nodejs.png"));
            subTopics.Add(new SubTopic("ReactJS", "ReactJS", null, "React.png"));

            List<SubTopic> subTopics2 = new List<SubTopic>();

            subTopics2.Add(new SubTopic("Bálint", "Én alapítottam a cuki lovagrendet ahol rózsaszín pónikon lovagló nyalókakardos csokipáncélos lovagok vannak :D", null, "Balint2.jpg"));
            subTopics2.Add(new SubTopic("Dávid", "#Wikipedia", null, "David.jpg"));
            subTopics2.Add(new SubTopic("Gábor", "Mester", null, "Gabor.jpg"));
            subTopics2.Add(new SubTopic("Google", "#HowToC#", null, "ggl.jpg"));
            subTopics2.Add(new SubTopic("Kávé", "GetCoffee();", null, "Coffee.jpg"));
            subTopics2.Add(new SubTopic("Kitty", "HelloKitty", null, "Kitty.jpg"));
            subTopics2.Add(new SubTopic("Krisztián", "MR.WolframAlpha", null, "Krisztian.jpg"));
            subTopics2.Add(new SubTopic("Kreativitás", "-5 Work Efficiency", null, "Creativity.jpg"));
            subTopics2.Add(new SubTopic("Levente", "Vérmáj, Pókember", null, "Levi.jpg"));
            subTopics2.Add(new SubTopic("MSDN", "Is this page helpful?", null, "MSDN.jpg"));
            subTopics2.Add(new SubTopic("RubberDuck", "and the best debugger award goes to", null, "RubberDuck.jpg"));
            subTopics2.Add(new SubTopic("StackOverFlow", "https:/www.http://stackoverflow.com/", null, "StackOverFlow.jpg"));

            subTopics2[0].Tests.Add(new Test(Test.TestType.String, "TestQuestion", Test.TestType.String, "TestAnswer"));
            subTopics2[0].Tests.Add(new Test(Test.TestType.String, "TestQuestion2", Test.TestType.String, "TestAnswer2"));

            data.Add(new Topic("Web Development", "Web Development", subTopics, "WEB.png"));
            data.Add(new Topic("Artificial Intelligence", "Artificial Intelligence", null, "ai.png"));
            data.Add(new Topic("eXtensible Markup Language", "eXtensible Markup Language", null, "xml.png"));
            data.Add(new Topic("C#", "C#", null, "cs.png"));
            data.Add(new Topic("WPF", "WPF", null, "wpf.png"));
            data.Add(new Topic("Készítők", "Készítők", subTopics2, "#Poni.jpg"));
        }

        public void GenerateSimpleData()
        {
            for (int i = 0; i < 10; i++)
            {
                List<SubTopic> subTopics = new List<SubTopic>();

                for (int j = 0; j < 10; j++)
                {
                    List<Content> content = new List<Content>();

                    for (int k = 0; k < 10; k++)
                    {
                        content.Add(new Content("ContentLeírás" + k));
                    }

                    subTopics.Add(new SubTopic("SubTopicCím" + j, "SubTopicLeírás" + j, content, GenerateIcon()));
                }
                data.Add(new Topic("TopicCím" + i, "TopicLeírás" + i, subTopics, GenerateIcon()));
            }
        }

        /// <summary>
        /// Memóriába ment adatot.
        /// </summary>
        public void Save(List<Topic> topicList)
        {
            data = topicList;
        }

        /// <summary>
        /// Memóriából betölt adatot.
        /// </summary>
        public List<Topic> Load()
        {
            return data;
        }

        public string GenerateIcon()
        {
            string imageName;
            Random rnd = new Random();

            switch (rnd.Next(0, 3))
            {
                case 0:
                    imageName = "ASD0.JPG";
                    break;
                case 1:
                    imageName = "ASD1.JPG";
                    break;
                default:
                    imageName = "DEFAULT.png";
                    break;
            }

            return imageName;
        }
    }
}
